package com.sunnay.controller;

import com.sunnay.entity.AppShopLiveInfoEntity;
import com.sunnay.entity.UserBidEntity;
import com.sunnay.service.AppShopLiveInfoService;
import com.sunnay.util.R;
import com.sunnay.vo.live.OfferVo;
import com.sunnay.web.ContextHelper;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/live")
public class LiveController {

    @Resource
    private AppShopLiveInfoService appShopLiveInfoService;

    @GetMapping("/list")
    public R<List<AppShopLiveInfoEntity>> liveShopList(){
        return R.ok(appShopLiveInfoService.liveShopList(ContextHelper.getSystemUser()));
    }

    /**
     *  小号列表
     */
    @GetMapping("/small/list")
    public R<List<UserBidEntity>> liveShopSmallList(){
        return R.ok(appShopLiveInfoService.liveShopSmallList(ContextHelper.getSystemUser()));
    }
    /**
     *  小号出价
     */
    @PostMapping("/offer")
    public R<Object> liveShopOffer(@RequestBody OfferVo offerVo) throws IOException {
        return R.ok(appShopLiveInfoService.liveShopOffer(offerVo,ContextHelper.getSystemUser()));
    }

    /**
     *  小号关注
     */
    @PostMapping("/attention")
    public R<Object> liveShopAttention(@RequestBody OfferVo offerVo){
        appShopLiveInfoService.liveShopAttention(offerVo,ContextHelper.getSystemUser());
        return R.ok();
    }

    /**
     * 小号发言
     */
    @PostMapping("/send-msg")
    public R<Object> sendMsgInfo(@RequestBody OfferVo offerVo){
        appShopLiveInfoService.sendMsgInfo(offerVo,ContextHelper.getSystemUser());
        return R.ok();
    }
    /**
     * 小号分享
     */
    @PostMapping("/share")
    public R<Object> shareRoom(@RequestBody OfferVo offerVo){
        appShopLiveInfoService.shareRoom(offerVo,ContextHelper.getSystemUser());
        return R.ok();
    }
}
